package com.augurit.smartform.database;

import java.sql.Clob;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.augurit.smartform.constant.PageConstant;

/**
 * 数据库表信息类
 * @author cuigeqiang
 *
 */
public class Table {
	private String pageId;												//唯一标识一个JSP页面
	private String name;
	private String fullName;
	private int version;
	private String cnName;
	private String category;
	private String description;
	private String creator;				
	private Date createTime;
	private String sourceXmlStr;
	private Table parent;
	private String pkColumn;
	private boolean smartform;
	private List<String> indexColumns=new ArrayList<String>();
	private List<String> uniqueColumns=new ArrayList<String>();
	private List<String> summaryColumns=new ArrayList<String>();		//汇总字段集合（工作流使用）
	private List<FKRelation> fKRelation=new ArrayList<FKRelation>();
	private List<Column> columns=new ArrayList<Column>();
	private List<Table> childTables=new ArrayList<Table>();
	private boolean inserting;
	private boolean selecting;
	private boolean updating;
	private boolean deleting;
	private Long idValue;												//插入语句执行后返回当前序列值
	public boolean isDeleting() {
		return deleting;
	}
	public void setDeleting(boolean deleting) {
		this.deleting = deleting;
	}
	public boolean isUpdating() {
		return updating;
	}
	public void setUpdating(boolean updating) {
		this.updating = updating;
	}
	public boolean isSelecting() {
		return selecting;
	}
	public void setSelecting(boolean selecting) {
		this.selecting = selecting;
	}
	public boolean isInserting() {
		return inserting;
	}
	public void setInserting(boolean inserting) {
		this.inserting = inserting;
	}
	public String getPageId() {
		return pageId;
	}
	public void setPageId(String pageId) {
		this.pageId = pageId;
	}
	public String getName() {
		return name.toUpperCase();
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getVersion() {
		return version;
	}
	public void setVersion(int version) {
		this.version = version;
	}
	public String getCnName() {
		return cnName;
	}
	public void setCnName(String cnName) {
		this.cnName = cnName;
	}
	public String getCategory() {
		return category;
	}
	public void setCategory(String category) {
		this.category = category;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getCreator() {
		return creator;
	}
	public void setCreator(String creator) {
		this.creator = creator;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	public String getSourceXmlStr() {
		return sourceXmlStr;
	}
	public void setSourceXmlStr(String sourceXmlStr) {
		this.sourceXmlStr = sourceXmlStr;
	}
	public String getFullName() {
		return fullName;
	}
	public void setFullName(String fullName) {
		this.fullName = fullName;
	}
	public String getPkColumn() {
		return pkColumn;
	}
	public void setPkColumn(String pkColumn) {
		this.pkColumn = pkColumn;
	}
	public Table getParent() {
		return parent;
	}
	public void setParent(Table parent) {
		this.parent = parent;
	}
	public List<Column> getColumn() {
		return columns;
	}
	public void setColumn(Column column) {
		this.columns.add(column);
	}
	public List<Table> getChildTables() {
		return childTables;
	}
	public void setChildTables(Table childTable) {
		this.childTables.add(childTable);
	}
	public List<String> getIndexColumns() {
		return indexColumns;
	}
	public void setIndexColumns(String indexColumn) {
		this.indexColumns.add(indexColumn);
	}
	public List<String> getUniqueColumns() {
		return uniqueColumns;
	}
	public void setUniqueColumns(String uniqueColumn) {
		this.uniqueColumns.add(uniqueColumn);
	}
	public List<FKRelation> getFKRelation() {
		return fKRelation;
	}
	public void setFKRelation(FKRelation relation) {
		fKRelation.add(relation);
	}
//	/**
//	 * 设置全名
//	 * @param fullName
//	 * @return
//	 * cuigeqiang
//	 */
//	public void setFullName(String fullName){
//		String[] splits=fullName.split(PageConstant.VERSION_FLAG);
//		if(splits.length>=2){
//			this.name=splits[0];
//			this.version=Integer.parseInt(splits[1]);
//		}
//	}
//	/**
//	 * 完整的数据库表名
//	 * @return
//	 * cuigeqiang
//	 */
//	public String getFullName() {
//		return this.getName()+PageConstant.VERSION_FLAG+this.version;
//	}
	/**
	 * 数据库表主键对应的序列名
	 * @return
	 * cuigeqiang
	 */
	public String getSequenceName() {
		return PageConstant.PREFIX_SEQUENCE+this.getFullName();
	}
	public boolean isSmartform() {
		return smartform;
	}
	public void setSmartform(boolean smartform) {
		this.smartform = smartform;
	}
	public Long getIdValue() {
		return idValue;
	}
	public void setIdValue(Long idValue) {
		this.idValue = idValue;
	}
	public List<String> getSummaryColumns() {
		return summaryColumns;
	}
	public void setSummaryColumns(String summaryColumn) {
		this.summaryColumns.add(summaryColumn);
	}
}
